package spring.mybatis.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import spring.mybatis.domain.User;
import spring.mybatis.mapper.UserMapper;

import java.util.List;

/**
 * service 层
 *
 * @author ME
 * @date 2021/5/20
 */
@Transactional(rollbackFor = Exception.class)
@Service
public class UserServiceImpl implements UserService {

    private final UserMapper mapper;

    @Autowired
    public UserServiceImpl(UserMapper mapper) {
        this.mapper = mapper;
    }

    @Override
    public Integer addUser(User user) {
        return mapper.addUser(user);
    }

    @Override
    public User getUser(Integer userId) {
        return mapper.getUser(userId);
    }

    @Override
    public List<User> getUsers() {
        return mapper.getUsers();
    }

}
